home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 1997
/
MacHack 1997.toast
/
Hacks
/
Hacks ’93
/
Mystery Science Mac
/
INIT sources
/
Utils.h
< prev
Wrap
C/C++ Source or Header
|
1993-09-01
|
4KB
|
145 lines
#pragma once
typedef unsigned char uchar;
typedef unsigned short ushort;
typedef unsigned long ulong;
extern struct Keyboard {
short wasted;
short wasted2;
short wasted3;
int command : 1;
int : 5;
int space : 1;
int tab : 1;
int : 4;
int control : 1;
int option : 1;
int capslock : 1;
int shift : 1;
} keymap : 0x174;
// this structure is useful for interpreting the fdFlags field of the FInfo structure.
typedef struct {
int isAlias : 1;
int isInvisible : 1;
int hasBundle : 1;
int nameLocked : 1;
int isStationery: 1;
int hasCustomIcn: 1;
int : 1;
int wasInited : 1;
int hasNoINITS : 1;
int isShared : 1;
int SwitchLaunch: 1;
int : 1;
int color : 3;
int : 1;
} FileFlags;
// SetA4 is an inline for setting register a4 without using inline assembly.
// it returns the old value of a4.
#pragma parameter __A0 SetA4(__A0)
pascal void *SetA4(void *newA4) = 0xC948;
// CopyHandle is a better interface to HandToHand.
#pragma parameter __A0 CopyHandle(__A0)
pascal void *CopyHandle(void *) = {0xA9E1};
// jbGetHandleSize is just GetHandleSize, without the error checks.
#pragma parameter __D0 jbGetHandleSize(__A0)
pascal Size jbGetHandleSize(void *h) = 0xA025;
// QuickMove is faster than BlockMove for very small moves and won't flush the cache.
// However, it always moves at least one byte!
#pragma parameter QuickMove(__A0, __A1, __D0)
pascal void QuickMove(void *from, void *to, short bytes) = {0x12D8, 0x5340, 0x62FA};
// MakeALong makes a long out of two shorts efficiently.
#pragma parameter __D0 MakeALong(__D0, __D1)
pascal long MakeALong(short HiWord, short LoWord) = {0x4840, 0x3001};
// MinShort takes the minimum of two input shorts efficiently
#pragma parameter __D0 MinShort(__D0, __D1)
pascal short MinShort (short a, short b) = {0xB240, 0x6E02, 0x3001};
// MaxShort takes the maximum of two input shorts efficiently
#pragma parameter __D0 MaxShort(__D0, __D1)
pascal short MaxShort (short a, short b) = {0xB240, 0x6D02, 0x3001};
// jbLoWord quickly retrieves the low word of a long..
#define jbLoWord(l) ((short)(l))
// jbHiWord quickly retrieves the high word of a long..
#pragma parameter __D0 jbHiWord(__D0)
pascal short jbHiWord(long Long) = {0x4840};
// jbDelay is a better interface for Delay.
#pragma parameter __A0 jbDelay(__A0)
pascal long jbDelay(long numTicks)
= {0xA03B};
// PenWhite calls PenPat(white) from QuickDraw's globals.
pascal void PenWhite(void)
= {0x2055, 0x4868, 0xFFF8, 0xA89D};
// PenBlack calls PenPat(black) from QuickDraw's globals.
pascal void PenBlack(void)
= {0x2055, 0x4868, 0xFFF0, 0xA89D};
// PenGray calls PenPat(gray) from QuickDraw's globals.
pascal void PenGray(void)
= {0x2055, 0x4868, 0xFFE8, 0xA89D};
// ArrowCursor calls SetCursor(arrow) from QuickDraw's globals.
pascal void ArrowCursor(void)
= {0x2055, 0x4868, 0xFF94, 0xA851};
// PStringMove is a quick pascal string copy using the toolbox.
#pragma parameter PStringMove(__A0,__A1)
pascal void PStringMove(const void *srcPtr,void *destPtr)
= {0x7001, 0xD010, 0xA02E};
// QStringMove is a quick inline pascal string copy. By not
// calling BlockMove it's faster and doesn't flush the cache.
#pragma parameter QStringMove(__A0,__A1)
pascal void QStringMove(const void *srcPtr,void *destPtr)
= {0x7000, 0x1010, 0x12D8, 0x51C8, 0xFFFC};
// a quicker inline for access to NumToString when you need it:
#pragma parameter iNumToString(__D0, __A0)
pascal void iNumToString(long theNum, void *theString) = {0x4267, 0xA9EE};
// a quicker inline for access to StringToNum when you need it:
#pragma parameter __D0 iStringToNum(__A0)
pascal long iStringToNum(void *theString) = {0x3F3C, 0x0001, 0xA9EE};
// Why HOpenResFile isn't declared this way, I don't know.
// (Under System 7, HORF has its own trap)
pascal short HOpenResFile7(short vRefNum,long dirID,ConstStr255Param fileName,
char permission) = 0xA81A;
// jbRelString is an interface to the RelString trap. It returns a result such
// that "jbRelString(s1, s2) > 0" returns the same as "s1 > s2", that is, zero
// if the strings are equal, 1 if s1 is greater that s2, -1 if neither.
extern short jbRelString(void *first, void *second);